package xilou.log4j;

import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;

import java.util.Properties;

/**
 * Created by yong on 2016/4/24.
 */
public class Example2 {
    public static void main (String[] arg) {
       //直接在代码里设置配置
        Properties prop = new Properties();
        prop.setProperty("log4j.rootLogger", "DEBUG, CONSOLE");
        prop.setProperty("log4j.appender.CONSOLE", "org.apache.log4j.ConsoleAppender");
        prop.setProperty("log4j.appender.CONSOLE.layout", "org.apache.log4j.PatternLayout");
        prop.setProperty("log4j.appender.CONSOLE.layout.ConversionPattern", "%d{HH:mm:ss,SSS} [%t] %-5p %C{1} : %m%n");
        PropertyConfigurator.configure(prop);

        Logger logger = Logger.getLogger(Example2.class);
        logger.info("log init ----------");
        logger.info(Example2.class);
    }
}
